#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
@Time        : 2021/11/18 13:02
@Author      : Albert Darren
@Contact     : 2563491540@qq.com
@File        : region_growing.py
@Version     : Version 1.0.0
@Description : TODO
@Created By  : PyCharm
"""
import SimpleITK as sitk
from DIP_experiment_5.util import contrast_show
from skimage.color import rgb2gray
import cv2 as cv

IM_PATH = "../experiment_fig/brain1.png"
seed = (208, 218)

im = rgb2gray(cv.imread(IM_PATH)) * 255
im_dict = {"Origin image": im}
img = sitk.GetImageFromArray(im)  # (519, 494)
upper = 90
region = sitk.ConnectedThreshold(img, seedList=[seed], lower=40, upper=upper, replaceValue=255)
region_arr = sitk.GetArrayViewFromImage(region)
im_dict["Region growing upper={}".format(upper)] = region_arr

contrast_show(im_dict, (1, 2), hspace=0.3)
